﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using IP.Core.IPCommon;
using IP.Core.IPException;
using IP.Core.IPData;
using IP.Core.IPUserService;
using IP.Core.IPSystemAdmin;
using BtdUS;
using BtdDS.CDBNames;
using BtdDS;

using C1.Win.C1FlexGrid;
using System.Collections;
using IP.Core.IPExcelReport;
using NCalc;


namespace BtdApp.ChucNang
{
    public partial class f700_lap_phuong_an_boi_thuong : Form
    {
        public f700_lap_phuong_an_boi_thuong()
        {
            InitializeComponent();

            format_controls();
        }
        #region Members
        DS_GD_PHUONG_AN_DETAIL m_ds_gd_pa_de = new DS_GD_PHUONG_AN_DETAIL();
        US_GD_PHUONG_AN_DETAIL m_us_gd_Pa_de = new US_GD_PHUONG_AN_DETAIL();
        US_GD_PHUONG_AN_BOI_THUONG m_us_gd_phuong_an_bt = new US_GD_PHUONG_AN_BOI_THUONG();
        DS_GD_PHUONG_AN_BOI_THUONG m_ds_gd_phuong_an_bt = new DS_GD_PHUONG_AN_BOI_THUONG();
        US_DM_DU_AN_BOI_THUONG m_us_dm_du_an_bt = new US_DM_DU_AN_BOI_THUONG();
        US_V_LOAI_VA_HANG_MUC m_us_v_loai_va_hang_muc = new US_V_LOAI_VA_HANG_MUC();
        US_CM_DM_TU_DIEN m_us_don_vi = new US_CM_DM_TU_DIEN();
        DS_BAO_CAO_PHUONG_AN_BT m_ds_dm_baocao = new DS_BAO_CAO_PHUONG_AN_BT();
        ITransferDataRow m_objTrans;
        ITransferDataRow m_objTrans_baocao;
        DataGridViewComboBoxColumn m_col_cbb_don_vi = new DataGridViewComboBoxColumn();
        eFormMode m_eformMode = eFormMode.LAP_PHUONG_AN_BOI_THUONG;
        #endregion

        #region Public Interfaces
        public void display()
        {
            m_eformMode = eFormMode.LAP_PHUONG_AN_BOI_THUONG;
            this.ShowDialog();
        }
        public void displayIsEdit(US_GD_PHUONG_AN_BOI_THUONG ip_us_phuong_an)
        {
            m_us_gd_phuong_an_bt = ip_us_phuong_an;
            m_eformMode = eFormMode.SUA_PHUONG_AN_BOI_THUONG;
            this.ShowDialog();
        }
        public void displayIsWiew(US_GD_PHUONG_AN_BOI_THUONG ip_us_phuong_an)
        {
            m_us_gd_phuong_an_bt = ip_us_phuong_an;
            m_eformMode = eFormMode.XEM_PHUONG_AN_BOI_THUONG;
            this.ShowDialog();
        }
        #endregion
        #region Data Structure
        private enum col_number
        {
            port_name = 1
        }
        private enum e_col_Number
        {
            MO_TA = 1,
            DON_VI = 2,
            CONG_THUC_SO_LUONG = 3,
            SO_LUONG = 4,
            DON_GIA = 5,
            HS_QD = 6,
            HS_DC = 7,
            THANH_TIEN = 8,
            GHI_CHU = 9,
            ID = 10,
            ID_PHUONG_AN = 11,
            ID_LOAI_HANG_MUC = 12
        }
        private enum e_col_Number_baocao
        {
            MO_TA = 1,
            DON_VI = 2,
            CONG_THUC_SO_LUONG = 3,            
            DON_GIA = 4,
            HS_QD = 5,
            HS_DC = 6,
            THANH_TIEN = 7,
            GHI_CHU = 8
        }
        public enum eFormMode
        {
            LAP_PHUONG_AN_BOI_THUONG,
            SUA_PHUONG_AN_BOI_THUONG,
            XEM_PHUONG_AN_BOI_THUONG
        }
        #endregion

        #region Private Methods
        private void format_controls()
        {
            CControlFormat.setFormStyle(this);//, new CAppContext_201(), IPFormStyle.DialogForm);
            CControlFormat.setC1FlexFormatCanEdit(m_fg);
            CGridUtils.AddSearch_Handlers(m_fg);
            m_fg.Tree.Style = C1.Win.C1FlexGrid.TreeStyleFlags.SimpleLeaf;
            m_fg.Cols[(int)e_col_Number.ID].Visible = false;
            m_fg.Cols[(int)e_col_Number.ID_LOAI_HANG_MUC].Visible = false;
            m_fg.Cols[(int)e_col_Number.ID_PHUONG_AN].Visible = false;
            m_fg.Tree.Column = (int)col_number.port_name;
            m_fg.Cols[(int)e_col_Number.DON_VI].DataMap = get_mapping_col_inventor_group();
            //m_fg.AutoSearch = AutoSearchEnum.None;
            this.KeyPreview = true;
            m_lbl_title.Font = new Font("Arial", 16);
            m_lbl_title.ForeColor = Color.DarkRed;
            m_lbl_title.TextAlign = ContentAlignment.MiddleCenter;
            m_fg.KeyActionTab = KeyActionEnum.MoveAcross;
            m_fg.KeyActionEnter = KeyActionEnum.MoveAcross;
            set_define_events();
        }

        private void set_initial_form_load()
        {
            m_objTrans = get_trans_object(m_fg);
            //add_cbb_don_vi_to_grid();  
            set_format_controls_by_form_mode();
            switch (m_eformMode)
            {
                case eFormMode.LAP_PHUONG_AN_BOI_THUONG:
                    display_data_in_to_grid_isnew();                    
                    break;
                case eFormMode.SUA_PHUONG_AN_BOI_THUONG:                    
                    us_phuong_ab_bt_2_form();
                    display_data_in_to_grid_isedit();
                    BaseMessages.MsgBox_Infor("Mọi chỉnh sửa trên lưới phải được chọn lưu trên từng dòng được thêm mới hoặc chỉnh sửa.");
                    break;
                case eFormMode.XEM_PHUONG_AN_BOI_THUONG:
                    us_phuong_ab_bt_2_form();
                    display_data_in_to_grid_isedit();
                    break;
                default:
                    break;
            }
        }
        private void set_format_controls_by_form_mode()
        {
            switch (m_eformMode)
            {
                case eFormMode.LAP_PHUONG_AN_BOI_THUONG:
                    m_txt_nguoi_lap.Text = CAppContext_201.getCurrentUser();                    
                    m_txt_ten_chu_ho.Text = "";                    
                    m_txt_so_thua.Text = "";            
                    m_txt_ghi_chu.Text = "";
                    m_txt_dia_chi.Text = "";
                    m_txt_ten_chu_ho.Focus();
                    break;
                case eFormMode.SUA_PHUONG_AN_BOI_THUONG:
                    m_cmd_insert.Text = "Cập nhật phương án";
                    m_cmd_chon_du_an.Enabled = false;
                    break;
                case eFormMode.XEM_PHUONG_AN_BOI_THUONG:
                    m_fg.AllowEditing = false;
                    m_fg.AutoSearch = AutoSearchEnum.FromTop;
                    m_cmd_insert.Visible = false;
                    m_gb_thong_tin_pa.Enabled = false;
                    m_cmd_xuat_excel.Visible = true;
                    m_fg.Cols[(int)e_col_Number.CONG_THUC_SO_LUONG].Visible = false;                    
                    break;
                default:
                    break;
            }
        }
        private ITransferDataRow get_trans_object(C1.Win.C1FlexGrid.C1FlexGrid i_fg)
        {
            Hashtable v_htb = new Hashtable();
            v_htb.Add(GD_PHUONG_AN_DETAIL.CONG_THUC_SO_LUONG, e_col_Number.CONG_THUC_SO_LUONG);
            v_htb.Add(GD_PHUONG_AN_DETAIL.MO_TA_HANG_MUC, e_col_Number.MO_TA);
            v_htb.Add(GD_PHUONG_AN_DETAIL.ID_DON_VI_TINH, e_col_Number.DON_VI);
            v_htb.Add(GD_PHUONG_AN_DETAIL.DON_GIA, e_col_Number.DON_GIA);
            v_htb.Add(GD_PHUONG_AN_DETAIL.HE_SO_QUY_DINH, e_col_Number.HS_QD);
            v_htb.Add(GD_PHUONG_AN_DETAIL.HE_SO_DIEU_CHINH, e_col_Number.HS_DC);
            v_htb.Add(GD_PHUONG_AN_DETAIL.THANH_TIEN, e_col_Number.THANH_TIEN);
            v_htb.Add(GD_PHUONG_AN_DETAIL.GHI_CHU, e_col_Number.GHI_CHU);
            v_htb.Add(GD_PHUONG_AN_DETAIL.ID, e_col_Number.ID);
            v_htb.Add(GD_PHUONG_AN_DETAIL.ID_PHUONG_AN, e_col_Number.ID_PHUONG_AN);
            v_htb.Add(GD_PHUONG_AN_DETAIL.ID_LOAI_HANG_MUC, e_col_Number.ID_LOAI_HANG_MUC);
            v_htb.Add(GD_PHUONG_AN_DETAIL.SO_LUONG, e_col_Number.SO_LUONG);
            ITransferDataRow v_obj_trans = new CC1TransferDataRow(i_fg, v_htb, m_ds_gd_pa_de.GD_PHUONG_AN_DETAIL.NewRow());
            return v_obj_trans;
        }

        private ITransferDataRow get_trans_object_baocao(C1.Win.C1FlexGrid.C1FlexGrid i_fg)
        {
            Hashtable v_htb = new Hashtable();
            v_htb.Add(BAO_CAO_PHUONG_AN_BT.CONG_THUC_SO_LUONG, e_col_Number_baocao.CONG_THUC_SO_LUONG);
            v_htb.Add(BAO_CAO_PHUONG_AN_BT.MO_TA, e_col_Number_baocao.MO_TA);
            v_htb.Add(BAO_CAO_PHUONG_AN_BT.DON_VI, e_col_Number_baocao.DON_VI);
            v_htb.Add(BAO_CAO_PHUONG_AN_BT.DON_GIA, e_col_Number_baocao.DON_GIA);
            v_htb.Add(BAO_CAO_PHUONG_AN_BT.HS_QD, e_col_Number_baocao.HS_QD);
            v_htb.Add(BAO_CAO_PHUONG_AN_BT.HS_DC, e_col_Number_baocao.HS_DC);
            v_htb.Add(BAO_CAO_PHUONG_AN_BT.THANH_TIEN, e_col_Number_baocao.THANH_TIEN);
            v_htb.Add(BAO_CAO_PHUONG_AN_BT.GHI_CHU, e_col_Number_baocao.GHI_CHU);
            ITransferDataRow v_obj_trans = new CC1TransferDataRow(i_fg, v_htb, m_ds_dm_baocao.BAO_CAO_PHUONG_AN_BT.NewRow());
            return v_obj_trans;
        }
        private void grid_2_us_object(US_GD_PHUONG_AN_DETAIL i_us_object, int i_GridRow)
        {
            DataRow v_dr = (DataRow)m_fg.Rows[i_GridRow].UserData;
            m_objTrans.GridRow2DataRow(i_GridRow, v_dr);
            i_us_object.DataRow2Me(v_dr);
        }

        private void us_object_2_grid(US_GD_PHUONG_AN_DETAIL i_us_object, DataSet i_ds
            , int i_grid_row)
        {
            if (m_fg.Rows[i_grid_row].UserData == null)
            {
                m_fg.Rows[i_grid_row].UserData = i_ds.Tables[0].NewRow();
            }
            DataRow v_dr = (DataRow)m_fg.Rows[i_grid_row].UserData;
            i_us_object.Me2DataRow(v_dr);
            m_objTrans.DataRow2GridRow(v_dr, i_grid_row);
        }
        //Add combobox

        /// <summary>
        /// Chuẩn bị data grid cho tạo mới phương án bồi thương.
        /// </summary>
        private void display_data_in_to_grid_isnew()
        {
            m_us_gd_Pa_de.load_loai_hang_muc_to_pa_de(m_ds_gd_pa_de);
            if (m_ds_gd_pa_de.GD_PHUONG_AN_DETAIL != null && m_ds_gd_pa_de.GD_PHUONG_AN_DETAIL.Rows.Count > 0)
                CGridUtils.ClearDataInGrid(m_fg);
            //m_objTrans.DataRow2GridRow(v_dr, i_grid_row);
            //1. Đặt dòng đầu của lưới là tên tổ chức            
            int v_i_new_grid_row = m_fg.Rows.Count - 1;
            foreach (DataRow item_dr_lhm in m_ds_gd_pa_de.GD_PHUONG_AN_DETAIL.Rows)
            {
                m_fg.Rows.Count++;
                v_i_new_grid_row++;                
                m_objTrans.DataRow2GridRow(item_dr_lhm, v_i_new_grid_row);                
                m_fg.Rows[v_i_new_grid_row].IsNode = true;
                m_fg.Rows[v_i_new_grid_row].Node.Level = 0;
                m_fg.Rows[v_i_new_grid_row].AllowEditing = false;
                m_fg.Rows[v_i_new_grid_row].UserData = item_dr_lhm;
                m_fg.Rows[v_i_new_grid_row].Style = m_fg.Styles["Subtotal0"];
                //Tạo 1 dòng trống
                insert_row_in_m_fg(v_i_new_grid_row, 1);                                 
                v_i_new_grid_row++;
                if (CIPConvert.ToDecimal(item_dr_lhm[GD_PHUONG_AN_DETAIL.ID]) == 2)
                {
                    m_fg.Rows[v_i_new_grid_row][(int)e_col_Number.HS_DC] = 1.7;
                    m_fg.Rows[v_i_new_grid_row][(int)e_col_Number.HS_QD] = 1;
                }
                if (CIPConvert.ToDecimal(item_dr_lhm[GD_PHUONG_AN_DETAIL.ID]) == 3 || CIPConvert.ToDecimal(item_dr_lhm[GD_PHUONG_AN_DETAIL.ID]) == 4)
                {
                    m_fg.Rows[v_i_new_grid_row][(int)e_col_Number.HS_DC] = 1;
                    m_fg.Rows[v_i_new_grid_row][(int)e_col_Number.HS_QD] = 1;
                }
            }
            m_fg.Select(2, 1);
        }
        /// <summary>
        /// Hiển thị danh sách hạng mục của phương án để sủa hoặc xem
        /// </summary>
        private void display_data_in_to_grid_isedit()
        {
            DS_GD_PHUONG_AN_DETAIL v_ds_dm_hang_muc = new DS_GD_PHUONG_AN_DETAIL();
            m_us_gd_Pa_de.load_loai_hang_muc_to_pa_de(m_ds_gd_pa_de);
            if (m_ds_gd_pa_de.GD_PHUONG_AN_DETAIL != null)
            {
                CGridUtils.ClearDataInGrid(m_fg);
                //m_objTrans.DataRow2GridRow(v_dr, i_grid_row);                       
                int v_i_new_grid_row = m_fg.Rows.Count - 1;
                foreach (DataRow item_dr_lhm in m_ds_gd_pa_de.GD_PHUONG_AN_DETAIL.Rows)
                {
                    m_fg.Rows.Count++;
                    v_i_new_grid_row++;
                    m_objTrans.DataRow2GridRow(item_dr_lhm, v_i_new_grid_row);
                    m_fg.Rows[v_i_new_grid_row].IsNode = true;
                    m_fg.Rows[v_i_new_grid_row].Node.Level = 0;
                    m_fg.Rows[v_i_new_grid_row].AllowEditing = false;
                    m_fg.Rows[v_i_new_grid_row].UserData = item_dr_lhm;
                    m_fg.Rows[v_i_new_grid_row].Style = m_fg.Styles["Subtotal0"];
                    //Thêm các hạng mục
                    v_ds_dm_hang_muc.Clear();
                    m_us_gd_Pa_de.Select_phuong_an_bt_de_by_id_loai_hm(v_ds_dm_hang_muc, m_us_gd_phuong_an_bt.dcID, CIPConvert.ToDecimal(item_dr_lhm[V_DM_LOAI_HANG_MUC_PA_DE.ID]));
                    if (v_ds_dm_hang_muc.GD_PHUONG_AN_DETAIL != null && v_ds_dm_hang_muc.GD_PHUONG_AN_DETAIL.Count > 0)
                    {
                        foreach (DataRow item in v_ds_dm_hang_muc.GD_PHUONG_AN_DETAIL.Rows)
                        {
                            m_fg.Rows.Count++;
                            v_i_new_grid_row++;
                            m_objTrans.DataRow2GridRow(item, v_i_new_grid_row);
                            m_fg.Rows[v_i_new_grid_row].IsNode = false;
                            m_fg.Rows[v_i_new_grid_row].Node.Level = 1;
                            m_fg.Rows[v_i_new_grid_row].UserData = item;

                        }
                    }
                    else
                    {
                        //Tạo 1 dòng trống                                                
                        insert_row_in_m_fg(v_i_new_grid_row, 1);
                        v_i_new_grid_row++;
                        //m_fg.Rows.Remove(v_i_new_grid_row);                       
                        //v_i_new_grid_row++;
                    }
                    //cong_tong_cac_hang_muc(v_i_new_grid_row);
                }
            }

        }
        /// <summary>
        /// Lưu phương án bồi thường.
        /// và dách các hạng mục của phương án.
        /// chỉ dùng cho tạo mới phương án.
        /// </summary>
        private void save_phuong_an_btd()
        {

            //DataRow v_da1 = m_ds_dm_loai_hang_muc.V_DM_LOAI_HANG_MUC_PA_DE.NewV_DM_LOAI_HANG_MUC_PA_DERow();
            try
            {
                m_us_gd_Pa_de.BeginTransaction();
                // cập nhật thông tin phương án bồi thường
                if (check_us_phuong_an_bt_isOK())
                {
                    form_2_us_phuong_ab_bt();
                    m_us_gd_phuong_an_bt.Insert();
                    for (int i = m_fg.Rows.Fixed; i < m_fg.Rows.Count; i++)
                    {
                        //Nếu Row là Node thì không lưu.
                        if (m_fg.Rows[i].IsNode) continue;
                        grid_2_us_object(m_us_gd_Pa_de, i);

                        m_us_gd_Pa_de.dcID_PHUONG_AN = m_us_gd_phuong_an_bt.dcID;
                        if (check_gia_tri_m_us(m_us_gd_Pa_de))
                        {
                            m_us_gd_Pa_de.Insert();
                        }

                    }
                    BaseMessages.MsgBox_Infor("Cập nhật thành công");
                    thiet_lap_phuong_an_moi_cho_form();
                }
                else
                    BaseMessages.MsgBox_Infor("Chưa điền đủ các thông tin cần thiết.");
                m_us_gd_Pa_de.CommitTransaction();

            }
            catch (Exception v_e)
            {
                m_us_gd_Pa_de.Rollback();
                throw v_e;
            }
        }
        private void update_phuong_an_btd()
        {

            //DataRow v_da1 = m_ds_dm_loai_hang_muc.V_DM_LOAI_HANG_MUC_PA_DE.NewV_DM_LOAI_HANG_MUC_PA_DERow();
            try
            {
                
                // cập nhật thông tin phương án bồi thường
                if (check_us_phuong_an_bt_isOK() == false) return;
                
                    form_2_us_phuong_ab_bt();
                    m_us_gd_phuong_an_bt.BeginTransaction();
                    m_us_gd_phuong_an_bt.Update();
                    m_us_gd_phuong_an_bt.CommitTransaction();
                    if (BaseMessages.MsgBox_Confirm("Dữ liệu đã cập nhật thành công. Bạn có lập phương án mới không?") == false)
                    {
                        this.Close();
                    }
                    else
                    {                        
                        thiet_lap_phuong_an_moi_cho_form();                        
                    }

            }
            catch (Exception v_e)
            {
                if (m_us_gd_phuong_an_bt.is_having_transaction())
                {
                    m_us_gd_phuong_an_bt.Rollback();
                }                
                throw v_e;
            }
        }
        /// <summary>
        /// chèn thêm 1 row trên grid
        /// </summary>
        /// <param name="v_i_cur_row"></param>
        /// <param name="ip_khoang_cach"></param>
        private void insert_row_in_m_fg(int v_i_cur_row, int ip_khoang_cach)
        {

            if (!CGridUtils.IsThere_Any_NonFixed_Row(m_fg)) return;
            if (!CGridUtils.isValid_NonFixed_RowIndex(m_fg, m_fg.Row)) return;
            int v_i_new_grid_row = v_i_cur_row + ip_khoang_cach;
            DataRow v_dr = m_ds_gd_pa_de.GD_PHUONG_AN_DETAIL.NewGD_PHUONG_AN_DETAILRow();
            m_fg.Rows.Insert(v_i_new_grid_row);

            decimal v_dc_parrent_loai_hang_muc =
                CIPConvert.ToDecimal(m_fg.Rows[v_i_new_grid_row].Node.Row[(int)e_col_Number.ID_LOAI_HANG_MUC]);
            v_dr[GD_PHUONG_AN_DETAIL.ID_LOAI_HANG_MUC] = v_dc_parrent_loai_hang_muc;
            m_fg.Rows[v_i_new_grid_row].IsNode = false;
            m_fg.Rows[v_i_new_grid_row].Node.Level = 1;
            m_objTrans.DataRow2GridRow(v_dr, v_i_new_grid_row);

            m_fg.Rows[v_i_new_grid_row].UserData = v_dr;
            if (!m_fg.Rows[v_i_new_grid_row - 1].IsNode)
                copy_du_lieu_dong_tren(v_i_new_grid_row);
        }

        private void copy_du_lieu_dong_tren(int ip_i_new_grid_row)
        {
            m_fg.Rows[ip_i_new_grid_row][(int)e_col_Number.DON_VI] = m_fg.Rows[ip_i_new_grid_row - 1][(int)e_col_Number.DON_VI];
            m_fg.Rows[ip_i_new_grid_row][(int)e_col_Number.HS_DC] = m_fg.Rows[ip_i_new_grid_row - 1][(int)e_col_Number.HS_DC];
            m_fg.Rows[ip_i_new_grid_row][(int)e_col_Number.HS_QD] = m_fg.Rows[ip_i_new_grid_row - 1][(int)e_col_Number.HS_QD];
        }
        /// <summary>
        /// Xóa rows trên grid
        /// </summary>
        private void delete_row_in_m_fg()
        {
            
            if (!CGridUtils.IsThere_Any_NonFixed_Row(m_fg)) return;
            if (!CGridUtils.isValid_NonFixed_RowIndex(m_fg, m_fg.Row)) return;
            if (m_fg.Rows[m_fg.Row].IsNode) return;
            if (IP.Core.IPCommon.BaseMessages.askUser_DataCouldBeDeleted() == BaseMessages.IsDataCouldBeDeleted.ShouldNotBeDeleted) return;
            int v_i_new_grid_row = m_fg.Selection.r1;
            int v_i_len = m_fg.Selection.r2;
            for (int i = v_i_new_grid_row; i <= v_i_len; i++)
            {
                m_fg.Rows.Remove(v_i_new_grid_row);
            }
        }
        //Lưu một dòng dùng
        private void save_row_in_m_fg_2_database()
        {
            if (m_fg.Rows[m_fg.Row].IsNode) return;
            grid_2_us_object(m_us_gd_Pa_de, m_fg.Row);
            m_us_gd_Pa_de.dcID_PHUONG_AN = m_us_gd_phuong_an_bt.dcID;
            if (check_gia_tri_m_us(m_us_gd_Pa_de))
            {
                if (m_us_gd_Pa_de.dcID < 0 || m_us_gd_Pa_de.IsIDNull())
                    m_us_gd_Pa_de.Insert();
                else
                    m_us_gd_Pa_de.Update();
            }


            BaseMessages.MsgBox_Infor("Cập nhật thành công.");
        }
        //Lưu một dòng dùng
        private void delete_row_in_m_fg_2_database()
        {
            if (IP.Core.IPCommon.BaseMessages.askUser_DataCouldBeDeleted() == BaseMessages.IsDataCouldBeDeleted.ShouldNotBeDeleted) return;
            if (!CGridUtils.IsThere_Any_NonFixed_Row(m_fg)) return;
            if (!CGridUtils.isValid_NonFixed_RowIndex(m_fg, m_fg.Row)) return;
            if (m_fg.Rows[m_fg.Row].IsNode) return;
            int v_i_new_grid_row = m_fg.Selection.r1;
            int v_i_len = m_fg.Selection.r2;
            for (int i = v_i_new_grid_row; i <= v_i_len; i++)
            {
                grid_2_us_object(m_us_gd_Pa_de, v_i_new_grid_row);
                m_fg.Rows.Remove(v_i_new_grid_row);
                if (!m_us_gd_Pa_de.IsIDNull())
                    m_us_gd_Pa_de.Delete();

            }
            BaseMessages.MsgBox_Infor("Cập nhật thành công.");
        }
        /// <summary>
        /// Hàm này để kiểm tra một dòng là để chống hay đã điền đủ dữ liệu chưa.
        /// </summary>
        /// <returns></returns>
        private bool check_gia_tri_m_us(US_GD_PHUONG_AN_DETAIL ip_us)
        {
            if (ip_us.IsMO_TA_HANG_MUCNull()) return false;
            if (ip_us.IsSO_LUONGNull()) return false;
            if (ip_us.IsDON_GIANull()) return false;
            //if (ip_us.IsID_DON_VI_TINHNull()) return false;
            if (ip_us.IsHE_SO_DIEU_CHINHNull()) return false;
            if (ip_us.IsHE_SO_QUY_DINHNull()) return false;
            return true;
        }
        //Tìm kiếm hạng mục
        private void seach_hang_muc()
        {
            if (m_fg.Col == (int)e_col_Number.DON_VI) return;
            string v_str = "";
            if (m_fg.Rows[m_fg.Row][(int)e_col_Number.MO_TA] != null)
                v_str = CAppContext_201.LocTuKhoaTimKiem(m_fg.Rows[m_fg.Row][(int)e_col_Number.MO_TA].ToString());
            f702_dm_loai_hm_hang_muc v_frm702 = new f702_dm_loai_hm_hang_muc();
            m_us_v_loai_va_hang_muc = v_frm702.display_to_select_hang_muc(v_str);
            //if (!m_us_v_loai_va_hang_muc.IsTEN_LOAINull())
            //    m_fg.Rows[m_fg.Row][(int)e_col_Number.MO_TA] = m_us_v_loai_va_hang_muc.strTEN_LOAI;
            if (!m_us_v_loai_va_hang_muc.IsDON_GIANull())
                m_fg.Rows[m_fg.Row][(int)e_col_Number.DON_GIA] = m_us_v_loai_va_hang_muc.dcDON_GIA;
            if (!m_us_v_loai_va_hang_muc.IsDON_VI_TINHNull())
                m_fg.Rows[m_fg.Row][(int)e_col_Number.DON_VI] = m_us_v_loai_va_hang_muc.dcID_DV_TINH;
        }

        //Chọn dự án từ form danh mục dự án
        private void chon_du_an_bt()
        {
            F500_DM_DU_AN_BOI_THUONG m_frm500 = new F500_DM_DU_AN_BOI_THUONG();
            m_us_dm_du_an_bt = m_frm500.chon_du_an();
            if (!m_us_dm_du_an_bt.IsIDNull())
                us_du_an_2_form();
            SendKeys.Send("{Tab}");
        }
        //Hàm dùng để gán tên dự án lên form
        private void us_du_an_2_form()
        {

            m_txt_ten_du_an.Text = m_us_dm_du_an_bt.strTEN_DU_AN;
            if (m_us_gd_phuong_an_bt.IsSO_THU_TUNull())
                m_txt_stt.Text = CIPConvert.ToStr(m_us_dm_du_an_bt.get_so_thu_tu_phuong_an_bt());
        }

        private void us_phuong_ab_bt_2_form()
        {
            m_txt_ten_chu_ho.Text = m_us_gd_phuong_an_bt.strTEN_CHU_HO;
            m_txt_dia_chi.Text = m_us_gd_phuong_an_bt.strDIA_CHI_CHU_HO;
            m_txt_so_thua.Text = m_us_gd_phuong_an_bt.strSO_THUA;
            m_txt_stt.Text = CIPConvert.ToStr(m_us_gd_phuong_an_bt.dcSO_THU_TU);
            m_txt_ghi_chu.Text = m_us_gd_phuong_an_bt.strGHI_CHU;
            m_txt_nguoi_lap.Text = m_us_gd_phuong_an_bt.strNGUOI_LAP;
            m_date_ngay_lap.Value = m_us_gd_phuong_an_bt.datNGAY_LAP;
            m_us_dm_du_an_bt = new US_DM_DU_AN_BOI_THUONG(m_us_gd_phuong_an_bt.dcID_DU_AN);
            us_du_an_2_form();
        }

        private void form_2_us_phuong_ab_bt()
        {
            m_us_gd_phuong_an_bt.dcID_DU_AN = m_us_dm_du_an_bt.dcID;
            m_us_gd_phuong_an_bt.strTEN_CHU_HO = m_txt_ten_chu_ho.Text;
            m_us_gd_phuong_an_bt.strDIA_CHI_CHU_HO = m_txt_dia_chi.Text;
            m_us_gd_phuong_an_bt.strSO_THUA = m_txt_so_thua.Text;
            m_us_gd_phuong_an_bt.dcSO_THU_TU = CIPConvert.ToDecimal(m_txt_stt.Text);
            m_us_gd_phuong_an_bt.strGHI_CHU = m_txt_ghi_chu.Text;
            m_us_gd_phuong_an_bt.dcID_DU_AN = m_us_dm_du_an_bt.dcID;
            m_us_gd_phuong_an_bt.strNGUOI_LAP = m_txt_nguoi_lap.Text;
            m_us_gd_phuong_an_bt.datNGAY_LAP = m_date_ngay_lap.Value;
        }
        private bool check_us_phuong_an_bt_isOK()
        {
            if (!CValidateTextBox.IsValid(m_txt_ten_chu_ho, DataType.StringType, allowNull.NO)) return false;
            if (!CValidateTextBox.IsValid(m_txt_stt, DataType.NumberType, allowNull.NO)) return false;
            return true;
        }

        private Hashtable get_mapping_col_inventor_group()
        {
            Hashtable v_hst = new Hashtable();
            DS_CM_DM_TU_DIEN v_ds_don_vi = new DS_CM_DM_TU_DIEN();
            m_us_don_vi.fill_tu_dien_cung_loai_ds("DON_VI_TINH", v_ds_don_vi);
            if (v_ds_don_vi.CM_DM_TU_DIEN != null && v_ds_don_vi.CM_DM_TU_DIEN.Count > 0)
            {
                foreach (DataRow v_dr in v_ds_don_vi.CM_DM_TU_DIEN)
                {
                    v_hst.Add(v_dr[CM_DM_TU_DIEN.ID], v_dr[CM_DM_TU_DIEN.TEN]);
                }
            }
            return v_hst;
        }
        private void add_cbb_don_vi_to_grid()
        {
            DS_CM_DM_TU_DIEN v_ds_don_vi = new DS_CM_DM_TU_DIEN();
            string v_str_cbb_don_vi = "";
            m_us_don_vi.fill_tu_dien_cung_loai_ds("DON_VI_TINH", v_ds_don_vi);
            if (v_ds_don_vi.CM_DM_TU_DIEN != null && v_ds_don_vi.CM_DM_TU_DIEN.Count > 0)
            {
                foreach (DataRow item in v_ds_don_vi.CM_DM_TU_DIEN)
                {
                    v_str_cbb_don_vi = v_str_cbb_don_vi + item[CM_DM_TU_DIEN.TEN].ToString() + "|";
                }
                v_str_cbb_don_vi = v_str_cbb_don_vi.Substring(0, v_str_cbb_don_vi.Length - 1);
            }
            m_fg.Cols[(int)e_col_Number.DON_VI].ComboList = v_str_cbb_don_vi;
        }
        private void cong_tong_cac_hang_muc(int ip_row)
        {
            //Lấy vị trí của dòng node
            int v_i_row_node = m_fg.Rows[ip_row].Node.Row.Index + 1;
            decimal v_dc_tong = 0;
            //Cộng tiền của các dòng con
            while (v_i_row_node < m_fg.Rows.Count && !m_fg.Rows[v_i_row_node].IsNode)
            {
                if (m_fg.Rows[v_i_row_node][(int)e_col_Number.THANH_TIEN] != null)
                    v_dc_tong = v_dc_tong + CIPConvert.ToDecimal(m_fg.Rows[v_i_row_node][(int)e_col_Number.THANH_TIEN]);
                v_i_row_node = v_i_row_node + 1;
            }
            m_fg.Rows[ip_row].Node.Row[(int)e_col_Number.THANH_TIEN] = v_dc_tong;
        }

        private void add_cac_muc_ho_tro()
        {
            DS_GD_PHUONG_AN_DETAIL v_ds_cac_muc_ho_tro = new DS_GD_PHUONG_AN_DETAIL();
            US_GD_PHUONG_AN_DETAIL v_us_cac_muc_ho_tro = new US_GD_PHUONG_AN_DETAIL();
            v_us_cac_muc_ho_tro.load_cac_muc_ho_tro_mac_dinh(v_ds_cac_muc_ho_tro);
            if (m_ds_gd_pa_de.GD_PHUONG_AN_DETAIL != null && m_ds_gd_pa_de.GD_PHUONG_AN_DETAIL.Rows.Count > 0)
                CGridUtils.ClearDataInGrid(m_fg);
            //m_objTrans.DataRow2GridRow(v_dr, i_grid_row);
            //1. Đặt dòng đầu của lưới là tên tổ chức            
            int v_i_new_grid_row = m_fg.Rows.Count - 1;
            foreach (DataRow item_dr_lhm in m_ds_gd_pa_de.GD_PHUONG_AN_DETAIL.Rows)
            {
                m_fg.Rows.Count++;
                v_i_new_grid_row++;
                m_objTrans.DataRow2GridRow(item_dr_lhm, v_i_new_grid_row);
                m_fg.Rows[v_i_new_grid_row].IsNode = true;
                m_fg.Rows[v_i_new_grid_row].Node.Level = 0;
                m_fg.Rows[v_i_new_grid_row].AllowEditing = false;
                m_fg.Rows[v_i_new_grid_row].UserData = item_dr_lhm;
                m_fg.Rows[v_i_new_grid_row].Style = m_fg.Styles["Subtotal0"];
                //Tạo 1 dòng trống
                insert_row_in_m_fg(v_i_new_grid_row, 1);
                v_i_new_grid_row++;
            }
        }
       
        private void tinh_so_luong_tu_o_cong_thuc()
        {
            try
            {
                if (m_fg.Rows[m_fg.Row].IsNode) return;
                if (m_fg.Rows[m_fg.Row][(int)e_col_Number.CONG_THUC_SO_LUONG] == null) return;
                if (CIPConvert.ToStr(m_fg.Rows[m_fg.Row][(int)e_col_Number.CONG_THUC_SO_LUONG]).Equals(""))
                {
                    m_fg.Rows[m_fg.Row][(int)e_col_Number.SO_LUONG] = 0;
                    return;
                }
                Expression v_ev = new Expression(CIPConvert.ToStr(m_fg.Rows[m_fg.Row][(int)e_col_Number.CONG_THUC_SO_LUONG]));
                m_fg.Rows[m_fg.Row][(int)e_col_Number.SO_LUONG] = v_ev.Evaluate();
                m_fg.Focus();
            }
            catch (Exception ex)
            {
                throw new Exception("Không phải công thức toán học.", ex);
            }
            
        }

        private void thiet_lap_phuong_an_moi_cho_form()
        {
            m_eformMode = eFormMode.LAP_PHUONG_AN_BOI_THUONG;
            m_txt_stt.Text = (CIPConvert.ToDecimal(m_txt_stt.Text) + 1).ToString();
            set_format_controls_by_form_mode();
            m_us_gd_phuong_an_bt.SetIDNull();
            display_data_in_to_grid_isnew();
        }
        private void chon_phuong_an_khac()
        {
            US_GD_PHUONG_AN_BOI_THUONG v_us_pa;
            if (m_us_dm_du_an_bt.IsIDNull())
            {
                BaseMessages.MsgBox_Infor("Chưa chọn dự án bồi thường.");
                return;
            }
            f701_dm_phuong_an_boi_thuong v_frm = new f701_dm_phuong_an_boi_thuong();
            v_us_pa = v_frm.displayIsSelect(m_us_dm_du_an_bt);
            if (v_us_pa == null) return;
            if (BaseMessages.MsgBox_Confirm("Những thay đổi chưa được lưu của phương án cũ sẽ bị xóa.") == false) return;
            m_us_gd_phuong_an_bt = v_us_pa;
            us_phuong_ab_bt_2_form();
            display_data_in_to_grid_isedit();
            m_eformMode = eFormMode.SUA_PHUONG_AN_BOI_THUONG;
            set_format_controls_by_form_mode();
        }
        
        #endregion

        #region Export Excel
        private void export_excel()
        {
            if (m_us_gd_phuong_an_bt.IsIDNull())
            {
                BaseMessages.MsgBox_Infor("Chưa chọn phương án bồi thường");
                return;
            }
            m_objTrans_baocao = get_trans_object_baocao(m_fg_baocao);            
            US_BAO_CAO_PHUONG_AN_BT v_us_hang_muc = new US_BAO_CAO_PHUONG_AN_BT();
            m_us_gd_Pa_de.load_loai_hang_muc_to_pa_de(m_ds_gd_pa_de);
            if (m_ds_gd_pa_de.GD_PHUONG_AN_DETAIL != null)
            {

                CExcelReport v_obj_export_excel = new CExcelReport("f702_bao_cao_phuong_an_boi_thuong3.xls", 21, 2);
                v_obj_export_excel.AddFindAndReplaceItem("<TEN_DU_AN>", m_txt_ten_du_an.Text.ToUpper());
                v_obj_export_excel.AddFindAndReplaceItem("<TEN_CHU_HO>", m_txt_ten_chu_ho.Text);
                v_obj_export_excel.AddFindAndReplaceItem("<DIA_CHI>", m_txt_dia_chi.Text);
                v_obj_export_excel.AddFindAndReplaceItem("<SO_THUA>", m_txt_so_thua.Text);
                v_obj_export_excel.AddFindAndReplaceItem("<NGUOI_LAP>", m_txt_nguoi_lap.Text);
                v_obj_export_excel.AddFindAndReplaceItem("<TEN_CHU_HO_2>", m_txt_ten_chu_ho.Text);
                v_obj_export_excel.AddFindAndReplaceItem("<STT>", m_txt_stt.Text);
                v_obj_export_excel.FindAndReplace(false);

                decimal ip_dong = 20;
                foreach (DataRow item_dr_lhm in m_ds_gd_pa_de.GD_PHUONG_AN_DETAIL.Rows)
                {
                    m_ds_dm_baocao.Clear();
                    CGridUtils.ClearDataInGrid(m_fg_baocao);
                    v_us_hang_muc.Select_phuong_an_bt_de_by_id_loai_hm(m_ds_dm_baocao, m_us_gd_phuong_an_bt.dcID, CIPConvert.ToDecimal(item_dr_lhm[V_DM_LOAI_HANG_MUC_PA_DE.ID]), ip_dong);
                    CGridUtils.Dataset2C1Grid(m_ds_dm_baocao, m_fg_baocao, m_objTrans_baocao);
                    v_obj_export_excel.GotoExportPosition((int)ip_dong + 1, 2);
                    v_obj_export_excel.Export2ExcelWithoutFixedRows(m_fg_baocao, (int)e_col_Number_baocao.MO_TA, m_fg_baocao.Cols.Count - 1, false);
                    ip_dong = ip_dong + m_ds_dm_baocao.BAO_CAO_PHUONG_AN_BT.Count + 2;
                }
            }
        }
        #endregion

        #region Events
        private void set_define_events()
        {
            this.Load += new EventHandler(f700_lap_phuong_an_boi_thuong_Load);
            m_tsm_themtruoc.Click += new EventHandler(thêmToolStripMenuItem_Click);
            m_tsm_themsau.Click += new EventHandler(m_tsm_themsau_Click);
            m_tsm_xoa.Click += new EventHandler(m_tsm_xoa_Click);
            m_fg.CellChanged += new RowColEventHandler(m_fg_CellChanged);
            m_cmd_insert.Click += new EventHandler(m_cmd_insert_Click);
            m_cmd_exit.Click += new EventHandler(m_cmd_exit_Click);
            this.KeyDown += new KeyEventHandler(f700_lap_phuong_an_boi_thuong_KeyDown);
            m_cmd_chon_du_an.Click += new EventHandler(m_cmd_chon_du_an_Click);
            m_cmd_xuat_excel.Click += new EventHandler(m_cmd_xuat_excel_Click);
            m_tsm_luu.Click += new EventHandler(m_tsm_luu_Click);
            m_cmd_chon_pa.Click += new EventHandler(m_cmd_chon_pa_Click);
        }

        void m_cmd_chon_pa_Click(object sender, EventArgs e)
        {
            try
            {
                chon_phuong_an_khac();
            }
            catch (Exception v_e)
            {
                CSystemLog_301.ExceptionHandle(v_e);
            }
        }                     

        void m_tsm_luu_Click(object sender, EventArgs e)
        {
            try
            {
                //Lưu hạng mục
                save_row_in_m_fg_2_database();
            }
            catch (Exception v_e)
            {
                CSystemLog_301.ExceptionHandle(v_e);
            }
        }

        void m_cmd_xuat_excel_Click(object sender, EventArgs e)
        {
            try
            {
                export_excel();
            }
            catch (Exception v_e)
            {
                CSystemLog_301.ExceptionHandle(v_e);
            }
        }

        void m_cmd_chon_du_an_Click(object sender, EventArgs e)
        {
            try
            {
                chon_du_an_bt();
            }
            catch (Exception v_e)
            {
                CSystemLog_301.ExceptionHandle(v_e);
            }
        }

        void f700_lap_phuong_an_boi_thuong_KeyDown(object sender, KeyEventArgs e)
        {
            try
            {
                switch (e.KeyCode)
                {
                    case Keys.F3:
                        //Thêm hạng mục suống dưới
                        if (m_eformMode == eFormMode.XEM_PHUONG_AN_BOI_THUONG) return;
                        insert_row_in_m_fg(m_fg.Row, 1);
                        break;
                    case Keys.F4:
                        //Tìm kiếm hạng mục
                        if (m_eformMode == eFormMode.XEM_PHUONG_AN_BOI_THUONG) return;
                        seach_hang_muc();
                        break;
                    case Keys.F5:
                        //Xóa hạng mục
                        if (m_eformMode == eFormMode.XEM_PHUONG_AN_BOI_THUONG) return;
                        delete_row_in_m_fg();
                        break;
                    case Keys.F6:
                        if (m_eformMode == eFormMode.XEM_PHUONG_AN_BOI_THUONG) return;
                        //Lưu hạng mục
                        save_row_in_m_fg_2_database();
                        break;                   
                    case Keys.Escape:
                        if (m_eformMode == eFormMode.XEM_PHUONG_AN_BOI_THUONG) { this.Close(); return; }
                        if (BaseMessages.MsgBox_Confirm("Nếu thoát mọi thông tin bạn vừa nhập sẽ không được lưu lại.") == true)
                            this.Close();
                        break;
                    case Keys.Tab:
                        if (m_fg.ColSel == (int)e_col_Number.GHI_CHU)
                        {
                            if ((m_fg.Rows[m_fg.Row][(int)e_col_Number.MO_TA] != null &&
                                m_fg.Rows[m_fg.Row][(int)e_col_Number.SO_LUONG] != null &&
                                m_fg.Rows[m_fg.Row][(int)e_col_Number.DON_GIA] != null &&
                                m_fg.Rows[m_fg.Row][(int)e_col_Number.HS_DC] != null &&
                                m_fg.Rows[m_fg.Row][(int)e_col_Number.HS_QD] != null) &&
                                (m_fg.Row + 1 == m_fg.Rows.Count || !(m_fg.Rows[m_fg.Row + 1][(int)e_col_Number.MO_TA] != null &&
                                m_fg.Rows[m_fg.Row + 1][(int)e_col_Number.SO_LUONG] != null &&
                                m_fg.Rows[m_fg.Row + 1][(int)e_col_Number.DON_GIA] != null &&
                                m_fg.Rows[m_fg.Row + 1][(int)e_col_Number.HS_DC] != null &&
                                m_fg.Rows[m_fg.Row + 1][(int)e_col_Number.HS_QD] != null)))
                                insert_row_in_m_fg(m_fg.Row, 1);
                        }
                        break;
                    default:
                        break;
                }
            }
            catch (Exception v_e)
            {
                CSystemLog_301.ExceptionHandle(v_e);
            }
        }

        void m_cmd_exit_Click(object sender, EventArgs e)
        {
            try
            {
                if (m_eformMode == eFormMode.XEM_PHUONG_AN_BOI_THUONG) { this.Close(); return; }
                if (BaseMessages.MsgBox_Confirm("Nếu thoát mọi thông tin bạn vừa nhập sẽ không được lưu lại.") == true)
                    this.Close();
            }
            catch (Exception v_e)
            {
                CSystemLog_301.ExceptionHandle(v_e);
            }
        }

        void m_cmd_insert_Click(object sender, EventArgs e)
        {

            //if (m_fg.Rows.Count < 5) return;                        
            try
            {
                switch (m_eformMode)
                {
                    case eFormMode.LAP_PHUONG_AN_BOI_THUONG:
                        save_phuong_an_btd();
                        break;
                    case eFormMode.SUA_PHUONG_AN_BOI_THUONG:
                        update_phuong_an_btd();
                        break;
                    case eFormMode.XEM_PHUONG_AN_BOI_THUONG:
                        break;
                    default:
                        break;
                }
            }
            catch (Exception v_e)
            {
                CSystemLog_301.ExceptionHandle(v_e);
            }
        }

        void m_fg_CellChanged(object sender, RowColEventArgs e)
        {
            try
            {
                if (!CGridUtils.IsThere_Any_NonFixed_Row(m_fg)) return;
                if (!CGridUtils.isValid_NonFixed_RowIndex(m_fg, m_fg.Row)) return;
                if (e.Col == (int)e_col_Number.CONG_THUC_SO_LUONG)
                {
                    tinh_so_luong_tu_o_cong_thuc();
                }
                if (e.Col == (int)e_col_Number.SO_LUONG ||
                    e.Col == (int)e_col_Number.DON_GIA ||
                    e.Col == (int)e_col_Number.HS_DC ||
                    e.Col == (int)e_col_Number.HS_QD)
                {
                    decimal v_so_luong = 0, v_don_gia = 0, v_hs_dc = 0, v_hs_qd = 0, v_dc_tong;
                    if (m_fg.Rows[e.Row][(int)e_col_Number.SO_LUONG] != null)
                        v_so_luong = CIPConvert.ToDecimal(m_fg.Rows[e.Row][(int)e_col_Number.SO_LUONG]);
                    if (m_fg.Rows[e.Row][(int)e_col_Number.DON_GIA] != null)
                        v_don_gia = CIPConvert.ToDecimal(m_fg.Rows[e.Row][(int)e_col_Number.DON_GIA]);
                    if (m_fg.Rows[e.Row][(int)e_col_Number.HS_DC] != null)
                        v_hs_dc = CIPConvert.ToDecimal(m_fg.Rows[e.Row][(int)e_col_Number.HS_DC]);
                    if (m_fg.Rows[e.Row][(int)e_col_Number.HS_QD] != null)
                        v_hs_qd = CIPConvert.ToDecimal(m_fg.Rows[e.Row][(int)e_col_Number.HS_QD]);
                    //MessageBox.Show("Hehe");         
                    v_dc_tong = v_so_luong * v_don_gia * v_hs_dc * v_hs_qd;
                    m_fg.Rows[e.Row][(int)e_col_Number.THANH_TIEN] = v_dc_tong;
                    cong_tong_cac_hang_muc(e.Row);
                }
            }
            catch (Exception v_e)
            {
                CSystemLog_301.ExceptionHandle(v_e);
            }
        }

        void m_tsm_xoa_Click(object sender, EventArgs e)
        {
            try
            {
                switch (m_eformMode)
                {
                    case eFormMode.LAP_PHUONG_AN_BOI_THUONG:
                        delete_row_in_m_fg();
                        break;
                    case eFormMode.SUA_PHUONG_AN_BOI_THUONG:
                        delete_row_in_m_fg_2_database();
                        break;
                    case eFormMode.XEM_PHUONG_AN_BOI_THUONG:
                        break;
                    default:
                        break;
                }
            }
            catch (Exception v_e)
            {
                CSystemLog_301.ExceptionHandle(v_e);
            }
        }

        void m_tsm_themsau_Click(object sender, EventArgs e)
        {
            try
            {
                if (m_eformMode == eFormMode.XEM_PHUONG_AN_BOI_THUONG) return;
                insert_row_in_m_fg(m_fg.Row, 1);
            }
            catch (Exception v_e)
            {
                CSystemLog_301.ExceptionHandle(v_e);
            }
        }

        void thêmToolStripMenuItem_Click(object sender, EventArgs e)
        {
            try
            {
                if (m_eformMode == eFormMode.XEM_PHUONG_AN_BOI_THUONG) return;
                if (m_fg.Row > m_fg.Rows.Fixed)
                    insert_row_in_m_fg(m_fg.Row, 0);
            }
            catch (Exception v_e)
            {
                CSystemLog_301.ExceptionHandle(v_e);
            }
        }

        void f700_lap_phuong_an_boi_thuong_Load(object sender, EventArgs e)
        {
            try
            {
                set_initial_form_load();
            }
            catch (Exception v_e)
            {
                CSystemLog_301.ExceptionHandle(v_e);
            }
        }
        #endregion
 
    }
}
